﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompositePattern.GeneralDemoOne
{
    /// <summary>
    /// 抽象構件
    /// </summary>
    public abstract class Component
    {
        /// <summary>
        /// 個體和整體都具有的共享
        /// </summary>
        public virtual string doSomething() {
            return "tree";
        }

        /// <summary>
        /// 增加一個葉子構件或樹枝構件
        /// </summary>
        /// <param name="component"></param>
        public abstract void add(Component component);

        /// <summary>
        /// 刪除一個葉子構件或樹枝構件
        /// </summary>
        /// <param name="component"></param>
        public abstract void remove(Component component);

        /// <summary>
        /// 獲得分支下的所有葉子構件和樹枝構件
        /// </summary>
        /// <param name="component"></param>
        public abstract List<Component> getChildren();
    }
}
